import multiprocessing
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt, pyqtSlot
from PyQt5.QtGui import QPixmap, QImage
from PyQt5.Qt import QShortcut

# from common.settings import Settings

from ui.base.BaseApp import BaseApp

__doc__ = 'GUI'


class App(BaseApp):
    def __init__(self):
        super(App, self).__init__(cam_matrix=(1, 1))

        # 拍照/本地读图进程 都受cam_ipc_control控制 1即工作 0即停止
        self.cam_ipc_control = multiprocessing.Value('B', lock=False)
        # 跨进程控制照片走不走模型
        self.ipc_flag_model_on = multiprocessing.Value('B', 1, lock=False)
        # 决定Basler拍多少张照片视作工件结束 UI设置页写 Basler进程读
        self.img_count_per_piece = multiprocessing.Value('I', 20, lock=False)
        # 当前进程数
        self.ready_p_cnt = multiprocessing.Value('B')
        self.image_producer_facade = None  # cam mode

        # 子界面
        # self.win_progress.ready_p_cnt = self.ready_p_cnt
        # self.win_progress.ready_p_total = len(self.MODEL_USAGE) + Settings.FLAG_IMG_FROM_CAM_LIST.count(True)  # 总进程数

        self.initUI()

        self.connect()

    def initUI(self):
        self.win_progress = None

    def connect(self):
        pass

    def dock_custom(self):
        data = [
            ('run_details', '运行详情', 150, None, Qt.RightDockWidgetArea),
        ]
        _ = [self.QDockBand(*item) for item in data]

    def run(self):
        """ 间隙 """
        pass


if __name__ == '__main__':
    import sys
    from PyQt5.Qt import QApplication

    app = QApplication(sys.argv)

    win = App()
    win.show()

    sys.exit(app.exec_())

